package com.gears_software.sxdc.dccx.data.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;

import com.gears_software.sxdc.dccx.data.model.RechargeAmount;
import com.gears_software.sxdc.dccx.ui.view.RechargeAmountListItemView;
import com.gears_software.sxdc.dccx.ui.view.RechargeAmountListItemView_;

import java.util.List;

/**
 * Created by SunMuran on 2017/8/12.
 * 充值列表的adapter
 */

public class RechargeAmountAdapter extends BaseAdapter{
    Context context;
    List<RechargeAmount> list;

    public RechargeAmountAdapter(Context context, List<RechargeAmount> list) {
        this.context = context;
        this.list = list;
    }

    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public Object getItem(int position) {
        return list.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        RechargeAmountListItemView itemView;
        if(convertView==null){
            itemView = RechargeAmountListItemView_.build(context);
        }else{
            itemView = (RechargeAmountListItemView) convertView;
        }
            itemView.bind(list.get(position));


        return itemView;
    }
}
